package cn.sym.org.controller;

import cn.sym.basic.query.BaseQuery;
import cn.sym.basic.util.AjaxResult;
import cn.sym.basic.util.PageList;
import cn.sym.org.aspect.anno.Operation;
import cn.sym.org.aspect.domain.Syslog;
import cn.sym.org.aspect.service.ISysLogService;
import cn.sym.org.domain.Department;
import cn.sym.org.query.DepartmentQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/syslog")
public class SysLogController {
    @Autowired
    private ISysLogService isysLogService;

    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable("id") Long id){
        System.out.println(id);
        try {
            isysLogService.remove(id);
            return AjaxResult.my();
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.my().setSuccess(false).setMessage("网络错误，请稍后再试！！1");
        }
    }

    @PatchMapping
    public AjaxResult remove(@RequestBody List<Long> ids){
        try {
            isysLogService.removeMore(ids);
            return AjaxResult.my();
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.my().setSuccess(false).setMessage("网络错误，请稍后再试！！1");
        }
    }

    @GetMapping
    public List<Syslog> queryAll(){
        return isysLogService.queryAll();
    }

    /**
     * 高级查询
     */
    @PostMapping
    public PageList<Syslog> queryPage(@RequestBody BaseQuery query){
        System.out.println(query);
        return isysLogService.queryPage(query);
    }
}
